import os
from PIL import Image
import  sys
sys.path.append('../')


def save_resize_img(img_path, img_path_train, width, height):
    if not os.path.exists(img_path_train):
        os.mkdir(img_path_train)
    number = 0
    for label_name in os.listdir(img_path):
        if not os.path.exists(img_path_train + '/'):
            os.mkdir(img_path_train + '/')
            print(label_name)
        for imgs_name in os.listdir(img_path + '/' + label_name):
            img = (Image.open(img_path + '/' + label_name + '/' + imgs_name))
            img = img.resize((width, height), Image.ANTIALIAS)
            number += 1
            img.save(img_path_train + '/' + str(number) + '.jpg')

    print("resize image finish!!!!!")


if __name__ == '__main__':
    save_resize_img('/media/wsn640/新加卷1/数据集/NormalVideo/NormalVideo/test',
                    '/media/wsn640/新加卷1/数据集/NormalVideo/NormalVideo/data', 640, 360)
